#include <vector>
#include <iostream>

int find_mem(std::vector<bool> &mem, int sz)
{
    if (sz == 0)
    {
        return -1;
    }

    int i = 0;
    int hp = i;
    int cnt = 0;
    while (i < mem.size())
    {
        cnt = 0;
        hp = i;
        while (i < mem.size())
        {
            if (mem[i])
            {
                i = i + 1;
                break;
            }
            cnt++;
            i = i + 1;
            if (cnt == sz)
            {
                break;
            }
        }
        if (cnt == sz)
        {
            break;
        }
    }

    if (cnt == sz)
    {
        for (int i = hp; i < hp + sz; i++)
        {
            mem[i] = true;
        }
        return hp;
    }
    else
    {
        return -1;
    }
}

int main()
{
    std::vector<bool> mem(100, false);
    int N;
    std::cin >> N;
    std::vector<std::pair<int, int>> used;
    std::vector<std::string> s_vec;
    for (int i = 0; i < N; i++)
    {
        std::string s;
        std::cin >> s;
        s_vec.push_back(s);
    }

    for (int i = 0; i < N; i++)
    {
        std::string s = s_vec[i];
        if (s.substr(0, 7) == "REQUEST")
        {
            int sz = std::stoi(s.substr(8));
            int ret = find_mem(mem, sz);
            if (ret == -1)
            {
                std::cout << "error" << std::endl;
            }
            else
            {
                std::cout << ret << std::endl;
                used.push_back({ret, sz});
            }
        }
        else if (s.substr(0, 7) == "RELEASE")
        {
            int hp = std::stoi(s.substr(8));
            bool flag = false;
            for (int k = 0; k < used.size(); k++)
            {
                if (used[k].first == hp)
                {
                    flag = true;
                    for (int j = hp; j < hp + used[k].second; j++)
                    {
                        mem[j] = false;
                    }
                    used.erase(used.begin() + k);

                    break;
                }
            }
            if (!flag)
            {
                std::cout << "error" << std::endl;
            }
        }
    }

    return 0;
}